package com.xyy.saas.payment.job.syncData;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.xyy.elasticjob.client.annotation.ElasticJobConf;
import com.xyy.saas.payment.service.PinganLoanService;
import com.xyy.saas.payment.service.XydLoanService;
import com.xyy.saas.payment.trace.AlarmService;
import com.xyy.saas.payment.trace.DingTalkMessage;
import com.xyy.saas.payment.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDate;

@ElasticJobConf(name = "xyy.elastic.job.manage.XydCheckFilePullJob", cron = "0 0 11 2 * ?")
@Slf4j
public class XydCheckFilePullJob implements SimpleJob {
    @Autowired
    private AlarmService alarmService;
    @Autowired
    private XydLoanService xydLoanService;

    @Override
    public void execute(ShardingContext shardingContext) {
        LocalDate localDate = LocalDate.now().minusMonths(1);
        int year = localDate.getYear();
        int month = localDate.getMonthValue();
        String checkDate = LocalDateTimeUtil.formatNormal(LocalDate.of(year, month, 1));
        xydLoanService.downloadAndSaveFinances(checkDate);
    }

}
